﻿@{
    ViewBag.Title = "Index";
}
@model IEnumerable<Data.Model.OnlineUsers>
<form method="post">
@Html.AntiForgeryToken()
<div class="querybar">
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td style="width:60%">
                姓名：<input type="text" class="mytext" id="Name" name="Name" value="@ViewBag.Name" />
                <input type="submit" name="Search" value="查询" class="mybutton" />
            </td>
            <td align="right" style="padding-right:15px;">
                <span>当前共有 @Model.Count() 人在线</span>
            </td>
        </tr>
    </table>
</div>
<div class="toolbar" style="margin-top:0; border-top:0;">
    <input type="submit" style="display:none;" value="d" id="ClearAll" name="ClearAll" />
    <a href="javascript:void(0);" onclick="clearAll();return false;"><span style="background-image:url(@Url.Content("~/Images/ico/group_green_remove.png"));">清除所有用户</span></a>
    <span class="toolbarsplit">&nbsp;</span>
    <input type="submit" style="display:none;" value="d" id="ClearSelect" name="ClearSelect" />
    <a href="javascript:void(0);" onclick="clearSelect();return false;"><span style="background-image:url(@Url.Content("~/Images/ico/contact_grey_remove.png"));">清除选择用户</span></a>
</div>
<table cellpadding="0" cellspacing="1" border="0" class="listtable">
    <thead>
        <tr>
            <th><input type="checkbox" onclick="checkAll(this.checked);" style="vertical-align:middle;" />姓名</th>
            <th>所在机构</th>
            <th>登录时间</th>
            <th>登录IP</th>
            <th>客户端信息</th>
        </tr>
    </thead>
    <tbody>
    @{
        foreach (var user in Model)
    {
        <tr>
            <td><input type="checkbox" value="@user.ID" name="checkbox_app" />@user.UserName</td>
            <td>@user.OrgName</td>
            <td>@user.LoginTime</td>
            <td>@user.IP</td>
            <td>@user.ClientInfo</td>
        </tr>
    }    
    }
    </tbody>
</table>
<div class="buttondiv"></div>
</form>
<script type="text/javascript">
    function checkAll(checked)
    {
        $("input[name='checkbox_app']").prop("checked", checked);
    }
    function clearAll()
    {
        if (confirm("您真的要清除所有在线用户吗?"))
        {
            $("#ClearAll").click();
            return true;
        }
    }
    function clearSelect()
    {
        if ($(":checked[name='checkbox_app']").size() == 0)
        {
            alert("您没有选择要清除的用户!");
            return false;
        }
        if (!confirm('您真的要清除所选用户吗?'))
        {
            return false;
        }
        $("#ClearSelect").click();
        return true;
    }
</script>